package com.dk.code;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @author zh
 * @Description TODO
 * @createTime 2023/4/20
 */
@Component
@CodeType(codeType = "SERIALNO")
public class SERIALNO implements CodeService {

    @Autowired
    StringRedisTemplate redisTemplate;

    @Override//时间
    public String code(String partType, Long ruleId) {
        /*流水号是空的  定义一个数字让他自增*/
        Long sum = redisTemplate.opsForValue().increment("SUM", 1);
        String s = sum.toString();//启动类一个注解   两行代码  redis自增  每分钟重置
        String str="00"+s;
        return str;
    }
}
